class_name EnemyBullet
extends Area2D

var speed := 150
var need_moving := true
@onready var animation_player: AnimationPlayer = $AnimationPlayer

func start(pos):
	position = pos
	add_to_group("enemy_bullets")

func destroy():
	need_moving = false
	animation_player.play("destroy")
	await animation_player.animation_finished
	queue_free()

func _ready() -> void:
	pass

func _process(delta: float) -> void:
	if need_moving:
		position.y += speed * delta


func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
	queue_free()
